
using System.Web.UI.HtmlControls;
using System;
using System.Configuration;
using System.Drawing;
using System.Data;
using System.Web.UI.WebControls;
using Microsoft.VisualBasic;
using System.Collections;
using System.Web.UI;
using System.Web;


using System.IO;
using System.Text;
using System.Drawing.Imaging;
//using com.ddsc.database;
using DDSC.OracleADO;
using com.ddsc.common;
using SMAS;
using System.Resources;
using System.Data.OracleClient;

//==================================================================================================
//程式編號   :           VNDW0071                    版本 :  1.00.00
//
//程式名稱   :			 樂e購商品文案維護
//
//系統分析師 :           Joe
//
//程式設計師 :           Tino
//
//編寫日期   :           2013/01/31

//修改記錄   :

//修改案編號      修改日期      修改人員          修改原因            修　改　內　容

//－－－－       －－－－      －－－－     －－－－－－－－       －－－－－－－－－－－－－－－－
//P3513M0025     20130131      TinoWeng                             Init                    I
//
//==================================================================================================
namespace smasb2b
{
    public class VNDW0071 : BasePage
    {

        DataBase DataBase = new DataBase();
        StringBuilder sb = new StringBuilder();
        ArrayList m_arrParam = new ArrayList();
        dbAccess dba = new dbAccess();
        protected System.Web.UI.HtmlControls.HtmlInputHidden hidDOC_SPEC_PIC;
        protected System.Web.UI.WebControls.Image imgDOC_SPEC_PIC;
        FunctionHandler FunctionHandler = new FunctionHandler();
        protected Telerik.WebControls.RadEditor redDOC_SPEC;
        protected ddscControlLibrary.SubmitButtonCtrl btnSaveDoc;
        protected ddscControlLibrary.SubmitButtonCtrl btnExit;
        protected ddscControlLibrary.SubmitButtonCtrl btnExitDoc;
        string strSPLIT = "@@@SPLIT@@@";
        string IMG_PATH = "/SMAS/IMAGE/B2C/B2C_IMAGES/";
        bool bolTest = true;


        #region  Web Form 設計工具產生的程式碼

        //此為 Web Form 設計工具所需的呼叫。
        [System.Diagnostics.DebuggerStepThrough()]
        private void InitializeComponent()
        {

        }
        protected System.Web.UI.WebControls.Label lblB2C_CODE;
        protected ddscControlLibrary.InputBoxCtrl txtB2C_CODE;
        protected System.Web.UI.WebControls.Label lblB2C_CODE_NAME;
        protected ddscControlLibrary.InputBoxCtrl txtB2C_CODE_NAME;
        protected ddscControlLibrary.SubmitButtonCtrl btnDelDoc;
        protected System.Web.UI.WebControls.Label lblDOC_VER;
        protected ddscControlLibrary.InputBoxCtrl txtDOC_VER;
        protected System.Web.UI.WebControls.Image imgDOC_PIC1_PATH;
        protected System.Web.UI.WebControls.Label lblDOC_PIC1_PATH;
        protected Telerik.WebControls.RadEditor redDOC_BODY_1;
        protected System.Web.UI.WebControls.Image Image1;
        protected System.Web.UI.HtmlControls.HtmlInputFile txtDOC_PIC1_PATH;
        protected System.Web.UI.HtmlControls.HtmlInputHidden hidDOC_PIC1_PATH;
        protected System.Web.UI.WebControls.Label lblBAS_DOC;
        protected System.Web.UI.WebControls.Label lblDOC_PIC;
        protected System.Web.UI.WebControls.CheckBox chkDOC_PIC1_PATH_DEL;
        protected System.Web.UI.WebControls.Image imgDOC_PIC2_PATH;
        protected System.Web.UI.WebControls.Label lblDOC_PIC2_PATH;
        protected System.Web.UI.WebControls.CheckBox chkDOC_PIC2_PATH_DEL;
        protected Telerik.WebControls.RadEditor redDOC_BODY_2;
        protected System.Web.UI.WebControls.Image imgDOC_PIC3_PATH;
        protected System.Web.UI.WebControls.Label lblDOC_PIC3_PATH;
        protected System.Web.UI.WebControls.CheckBox chkDOC_PIC3_PATH_DEL;
        protected Telerik.WebControls.RadEditor redDOC_BODY_3;
        protected System.Web.UI.WebControls.Image imgDOC_PIC4_PATH;
        protected System.Web.UI.WebControls.Label lblDOC_PIC4_PATH;
        protected System.Web.UI.WebControls.CheckBox chkDOC_PIC4_PATH_DEL;
        protected Telerik.WebControls.RadEditor redDOC_BODY_4;
        protected System.Web.UI.WebControls.Image imgDOC_PIC5_PATH;
        protected System.Web.UI.WebControls.Label lblDOC_PIC5_PATH;
        protected System.Web.UI.WebControls.CheckBox chkDOC_PIC5_PATH_DEL;
        protected Telerik.WebControls.RadEditor redDOC_BODY_5;
        protected System.Web.UI.WebControls.Label lblDOC_SPEC;
        protected System.Web.UI.HtmlControls.HtmlTable DOC_PIC_TABLE;
        protected System.Web.UI.HtmlControls.HtmlInputFile txtDOC_PIC2_PATH;
        protected System.Web.UI.HtmlControls.HtmlInputHidden hidDOC_PIC2_PATH;
        protected System.Web.UI.HtmlControls.HtmlInputFile txtDOC_PIC3_PATH;
        protected System.Web.UI.HtmlControls.HtmlInputHidden hidDOC_PIC3_PATH;
        protected System.Web.UI.HtmlControls.HtmlInputFile txtDOC_PIC4_PATH;
        protected System.Web.UI.HtmlControls.HtmlInputHidden hidDOC_PIC4_PATH;
        protected System.Web.UI.HtmlControls.HtmlInputFile txtDOC_PIC5_PATH;
        protected System.Web.UI.HtmlControls.HtmlInputHidden hidDOC_PIC5_PATH;
        protected System.Web.UI.HtmlControls.HtmlTable Table2;
        protected System.Web.UI.WebControls.Label lblDOC_SPEC_PIC;
        protected System.Web.UI.WebControls.CheckBox chkDOC_SPEC_PIC;
        protected System.Web.UI.HtmlControls.HtmlInputFile txtDOC_SPEC_PIC;
        protected ddscControlLibrary.SubmitButtonCtrl btnPreviewDoc;
        protected ddscControlLibrary.SubmitButtonCtrl btnApproveDoc;

        //注意: 下列預留位置宣告是 Web Form 設計工具需要的項目。
        //請勿刪除或移動它。
        private System.Object designerPlaceholderDeclaration;

        private void Page_Init(System.Object sender, System.EventArgs e)
        {
            //CODEGEN: 此為 Web Form 設計工具所需的方法呼叫

            //20130701 Johnny 判斷是否在正式環境
            if (Environment.MachineName.Trim() == "SMASWEB01" || Environment.MachineName.Trim() == "SMASWEB02" || Environment.MachineName.Trim() == "SMASB2B01")
            {
                bolTest = false;
            }
            //請勿使用程式碼編輯器進行修改。
            InitializeComponent();
        }

        #endregion

        private DataTable createErrorTable(string mError)
        {

            dbReturnInfo dbInfo = new dbReturnInfo("info");
            dbInfo.AddNewRow();
            dbInfo.setReturnDataValue("F", System.Convert.ToString(999), 0, mError);
            return dbInfo.getReturnDataTable();
        }

        private string[] GetDocBody(string sDest, string s)
        {
            string[] ss = new string[3];
            if (sDest.IndexOf(s) == -1)
            {
                ss[0] = sDest;
                ss[1] = "";
            }
            else
            {
                ss[0] = sDest.Substring(0, sDest.IndexOf(s));
                ss[1] = sDest.Substring(System.Convert.ToInt32(sDest.IndexOf(s) + s.Length));
            }

            return ss;
        }

        private void Page_Load(System.Object sender, System.EventArgs e)
        {
            //在這裡放置使用者程式碼以初始化網頁
            try
            {
                if (!Page.IsPostBack)
                {
                    ShowPage(false);
                }
            }
            catch (Exception ex)
            {
                showException(ex.Message);
            }
            this.btnApproveDoc.Click +=btnApproveDoc_Click;

            this.btnDelDoc.Click +=btnDelDoc_Click;

            this.btnPreviewDoc.Click +=btnPreviewDoc_Click;

            this.btnSaveDoc.Click +=btnSaveDoc_Click;
        }

        private void ShowPage(bool IsReShow)
        {
            this.txtB2C_CODE.Text = (dynamic)System.Convert.ToString(this.Request["B2C_CODE"].ToString().Trim());

            DataBase.clearSB(sb);
            //Tony : 1.修改SQL語法使用參數，不組字串
            //sb.Append(" SELECT B2C_CODE_NAME  from B2C_CODE_MAPPING_MASTER WHERE B2C_CODE = \'" + this.Request["B2C_CODE"].ToString().Trim() + "\' ");
            sb.Append(" SELECT B2C_CODE_NAME  from B2C_CODE_MAPPING_MASTER WHERE B2C_CODE = :B2C_CODE ");

            //Tony : 2.設定動態參數物件
            m_arrParam.Add(dba.GetOracleParam(":B2C_CODE", this.Request["B2C_CODE"].ToString().Trim()));

            //Tony : 3.修改執行方法Overload
            //DataSet ds_name = DataBase.Query_CLASS(sb);
            DataSet ds_name = DataBase.Query_CLASS(sb, m_arrParam);

            if (!(ds_name == null) && ds_name.Tables[0].Rows[0]["ReturnCode"] != "100" && ds_name.Tables[0].Rows[0]["ReturnCode"] != "999")
            {
                this.txtB2C_CODE_NAME.Text = System.Convert.ToString(ds_name.Tables[1].Rows[0][0]);
            }
            //Me.txtB2C_CODE_NAME.Text = System.Web.HttpUtility.UrlDecode(Me.Request("B2C_CODE_NAME1").ToString().Trim(), System.Text.Encoding.GetEncoding("UTF-8"))
            if (!IsReShow)
            {
                this.txtDOC_VER.Text = (dynamic)(this.Request["DOC_VER"].ToString().Trim());
            }

            this.btnApproveDoc.Visible = true;
            this.btnDelDoc.Visible = true;
            this.btnSaveDoc.Visible = true;
            EnableView_DOC_SPEC_Controls(true);
            bool ShowImgControl = false;
            bool ShowChkControl = false;
            if ((string)(Page.Request["action_type"].ToUpper()) == "ADD")
            {
                ShowImgControl = true;
                ShowChkControl = true;
                this.btnDelDoc.Visible = false;
                if (!IsReShow)
                {
                    DataBase.clearSB(sb);
                    sb.Append(" SELECT NVL(MAX(DOC_VER),0)  from B2C_WEB_CONTENT ");
                    //Tony : 1.修改SQL語法使用參數，不組字串
                    //sb.Append(" WHERE  CODE = \'" + this.txtB2C_CODE.Text + "\'");
                    sb.Append(" WHERE  CODE = :B2C_CODE");

                    //Tony:2..設定動態參數物件
                    m_arrParam.Clear();
                    m_arrParam.Add(dba.GetOracleParam(":B2C_CODE", this.txtB2C_CODE.Text));

                    //Tony : 3.修改執行方法Overload
                    //DataSet ds_ver = DataBase.Query_CLASS(sb);
                    DataSet ds_ver = DataBase.Query_CLASS(sb, m_arrParam);

                    if (!(ds_ver == null) && ds_ver.Tables[0].Rows[0]["ReturnCode"] != "100" && ds_ver.Tables[0].Rows[0]["ReturnCode"] != "999")
                    {
                        txtDOC_VER.Text = System.Convert.ToString((Convert.ToInt32(ds_ver.Tables[1].Rows[0][0]) + 1).ToString("D4"));
                    }

                    this.chkDOC_SPEC_PIC.Visible = false;
                    this.chkDOC_PIC1_PATH_DEL.Visible = false;
                    this.chkDOC_PIC2_PATH_DEL.Visible = false;
                    this.chkDOC_PIC3_PATH_DEL.Visible = false;
                    this.chkDOC_PIC4_PATH_DEL.Visible = false;
                    this.chkDOC_PIC5_PATH_DEL.Visible = false;
                    //20130207,add,walter,把值也設成false
                    this.chkDOC_SPEC_PIC.Checked = false;
                    this.chkDOC_PIC1_PATH_DEL.Checked = false;
                    this.chkDOC_PIC2_PATH_DEL.Checked = false;
                    this.chkDOC_PIC3_PATH_DEL.Checked = false;
                    this.chkDOC_PIC4_PATH_DEL.Checked = false;
                    this.chkDOC_PIC5_PATH_DEL.Checked = false;
                    //-end


                    this.imgDOC_PIC1_PATH.Visible = false;
                    this.imgDOC_PIC2_PATH.Visible = false;
                    this.imgDOC_PIC3_PATH.Visible = false;
                    this.imgDOC_PIC4_PATH.Visible = false;
                    this.imgDOC_PIC5_PATH.Visible = false;
                    this.imgDOC_SPEC_PIC.Visible = false;
                }
            }
            else if ((string)(Page.Request["action_type"].ToUpper()) == "EDIT")
            {
                ShowImgControl = true;
                ShowChkControl = true;
                this.btnDelDoc.Visible = false;
                this.chkDOC_SPEC_PIC.Checked = false;
                this.chkDOC_PIC1_PATH_DEL.Checked = false;
                this.chkDOC_PIC2_PATH_DEL.Checked = false;
                this.chkDOC_PIC3_PATH_DEL.Checked = false;
                this.chkDOC_PIC4_PATH_DEL.Checked = false;
                this.chkDOC_PIC5_PATH_DEL.Checked = false;
            }
            else if ((string)(Page.Request["action_type"].ToUpper()) == "PREVIEW")
            {
                ShowImgControl = true;
                ShowChkControl = false;
                this.btnDelDoc.Visible = false;
                this.btnSaveDoc.Visible = false;
                this.btnApproveDoc.Visible = false;
                EnableView_DOC_SPEC_Controls(false);
            }
            else if ((string)(Page.Request["action_type"].ToUpper()) == "DELETE")
            {
                ShowImgControl = true;
                ShowChkControl = false;
                this.btnSaveDoc.Visible = false;
                this.btnApproveDoc.Visible = false;
                EnableView_DOC_SPEC_Controls(false);
            }
            if (!(this.Request["GET_OLD"] == "" && Page.Request["action_type"].ToUpper() == "ADD") || IsReShow)
            {
                int numValue;
                DataBase.clearSB(sb);
                sb.Append(" Select * from B2C_WEB_CONTENT ");
                if (this.Request["GET_OLD"] == "Y")
                {
                    //Tony : 1.修改SQL語法使用參數，不組字串
                    //sb.Append(" WHERE  CODE = \'" + this.txtB2C_CODE.Text + "\' AND DOC_VER =\'" + (System.Convert.ToInt32(this.Request["DOC_VER"])).ToString() + "\'");
                    sb.Append(" WHERE  CODE = :B2C_CODE AND DOC_VER =:DOC_VER");
                    //Tony : 2.設定動態參數物件
                    m_arrParam.Clear();
                    m_arrParam.Add(dba.GetOracleParam(":B2C_CODE", this.txtB2C_CODE.Text));
                    m_arrParam.Add(dba.GetOracleParam(":DOC_VER", (System.Convert.ToInt32(this.Request["DOC_VER"])).ToString()));
                }
                else
                {
                    //Tony : 1.修改SQL語法使用參數，不組字串
                    //sb.Append(" WHERE  CODE = \'" + this.txtB2C_CODE.Text + "\' AND DOC_VER =\'" + (int.Parse(this.txtDOC_VER.Text)).ToString() + "\'");
                    sb.Append(" WHERE  CODE = :B2C_CODE AND DOC_VER =:DOC_VER");
                    //Tony : 2.設定動態參數物件
                    m_arrParam.Clear();
                    m_arrParam.Add(dba.GetOracleParam(":B2C_CODE", this.txtB2C_CODE.Text));
                    m_arrParam.Add(dba.GetOracleParam(":DOC_VER", (int.Parse(this.txtDOC_VER.Text)).ToString()));
                }
                //Tony:3.修改執行方法Overload
                //DataSet ds_detal = DataBase.Query_CLASS(sb);
                DataSet ds_detal = DataBase.Query_CLASS(sb, m_arrParam);
                int i = 0;
                if (!(ds_detal == null) && ds_detal.Tables[0].Rows[0]["ReturnCode"] != "100" && ds_detal.Tables[0].Rows[0]["ReturnCode"] != "999")
                {

                    for (i = 0; i <= ds_detal.Tables[1].Rows.Count - 1; i++)
                    {
                        DataRow dr = ds_detal.Tables[1].Rows[i];
                        int aInt = 9;
                        string[] arrDOC_BODY = new string[aInt + 1];
                        string sDest = "";
                        string sArr = dr["DOC_BODY"].ToString();
                        for (int iArr = 0; iArr <= aInt - 1; iArr++)
                        {
                            string[] ss = new string[3];
                            if (iArr == 0)
                            {
                                sDest = sArr;
                            }
                            ss = GetDocBody(sDest, strSPLIT);
                            arrDOC_BODY[iArr] = HttpUtility.HtmlDecode(ss[0]);
                            sDest = ss[1];
                        }
                        //arrDOC_BODY = dr("DOC_BODY").ToString.Split(strSPLIT.ToCharArray())
                        string strDOCP = string.Empty;
                        this.redDOC_BODY_1.Html = arrDOC_BODY[0];
                        if (dr["DOC_PIC1_PATH"].ToString() != "")
                        {

                            this.chkDOC_PIC1_PATH_DEL.Visible = ShowChkControl;
                            this.imgDOC_PIC1_PATH.Visible = ShowImgControl;
                            this.hidDOC_PIC1_PATH.Value = System.Convert.ToString(dr["DOC_PIC1_PATH"].ToString());
                            if (bolTest)
                            {
                                this.imgDOC_PIC1_PATH.ImageUrl = System.Convert.ToString(dr["DOC_PIC1_PATH"].ToString().Replace("\\\\Jing-preordervm\\", "http://localhost/"));
                            }
                            else
                            {
                                strDOCP = System.Convert.ToString(dr["DOC_PIC1_PATH"].ToString());
                                if (strDOCP.Substring(0, 2) == "\\\\")
                                {
                                    strDOCP = IMG_PATH + strDOCP.Substring(38);
                                }
                                this.imgDOC_PIC1_PATH.ImageUrl = strDOCP;
                            }
                        }
                        else
                        {
                            this.chkDOC_PIC1_PATH_DEL.Visible = false;
                            this.imgDOC_PIC1_PATH.Visible = false;
                        }
                        this.redDOC_BODY_2.Html = arrDOC_BODY[1];
                        if (dr["DOC_PIC2_PATH"].ToString() != "")
                        {
                            this.chkDOC_PIC2_PATH_DEL.Visible = ShowChkControl;
                            this.imgDOC_PIC2_PATH.Visible = ShowImgControl;
                            this.hidDOC_PIC2_PATH.Value = System.Convert.ToString(dr["DOC_PIC2_PATH"].ToString());
                            if (bolTest)
                            {
                                this.imgDOC_PIC2_PATH.ImageUrl = System.Convert.ToString(dr["DOC_PIC2_PATH"].ToString().Replace("\\\\Jing-preordervm\\", "http://localhost/"));
                            }
                            else
                            {
                                strDOCP = System.Convert.ToString(dr["DOC_PIC2_PATH"].ToString());
                                if (strDOCP.Substring(0, 2) == "\\\\")
                                {
                                    strDOCP = IMG_PATH + strDOCP.Substring(38);
                                }
                                this.imgDOC_PIC2_PATH.ImageUrl = strDOCP;
                            }

                        }
                        else
                        {
                            this.chkDOC_PIC2_PATH_DEL.Visible = false;
                            this.imgDOC_PIC2_PATH.Visible = false;
                        }
                        this.redDOC_BODY_3.Html = arrDOC_BODY[2];
                        if (dr["DOC_PIC3_PATH"].ToString() != "")
                        {
                            this.chkDOC_PIC3_PATH_DEL.Visible = ShowChkControl;
                            this.imgDOC_PIC3_PATH.Visible = ShowImgControl;
                            this.hidDOC_PIC3_PATH.Value = System.Convert.ToString(dr["DOC_PIC3_PATH"].ToString());
                            if (bolTest)
                            {
                                this.imgDOC_PIC3_PATH.ImageUrl = System.Convert.ToString(dr["DOC_PIC3_PATH"].ToString().Replace("\\\\Jing-preordervm\\", "http://localhost/"));
                            }
                            else
                            {
                                strDOCP = System.Convert.ToString(dr["DOC_PIC3_PATH"].ToString());
                                if (strDOCP.Substring(0, 2) == "\\\\")
                                {
                                    strDOCP = IMG_PATH + strDOCP.Substring(38);
                                }
                                this.imgDOC_PIC3_PATH.ImageUrl = strDOCP;
                            }

                        }
                        else
                        {
                            this.chkDOC_PIC3_PATH_DEL.Visible = false;
                            this.imgDOC_PIC3_PATH.Visible = false;
                        }
                        this.redDOC_BODY_4.Html = arrDOC_BODY[3];
                        if (dr["DOC_PIC4_PATH"].ToString() != "")
                        {
                            this.chkDOC_PIC4_PATH_DEL.Visible = ShowChkControl;
                            this.imgDOC_PIC4_PATH.Visible = ShowImgControl;
                            this.hidDOC_PIC4_PATH.Value = System.Convert.ToString(dr["DOC_PIC4_PATH"].ToString());
                            if (bolTest)
                            {
                                this.imgDOC_PIC4_PATH.ImageUrl = System.Convert.ToString(dr["DOC_PIC4_PATH"].ToString().Replace("\\\\Jing-preordervm\\", "http://localhost/"));
                            }
                            else
                            {
                                strDOCP = System.Convert.ToString(dr["DOC_PIC4_PATH"].ToString());
                                if (strDOCP.Substring(0, 2) == "\\\\")
                                {
                                    strDOCP = IMG_PATH + strDOCP.Substring(38);
                                }
                                this.imgDOC_PIC4_PATH.ImageUrl = strDOCP;
                            }

                        }
                        else
                        {
                            this.chkDOC_PIC4_PATH_DEL.Visible = false;
                            this.imgDOC_PIC4_PATH.Visible = false;
                        }
                        this.redDOC_BODY_5.Html = arrDOC_BODY[4];
                        if (dr["DOC_PIC5_PATH"].ToString() != "")
                        {
                            this.chkDOC_PIC5_PATH_DEL.Visible = ShowChkControl;
                            this.imgDOC_PIC5_PATH.Visible = ShowImgControl;
                            this.hidDOC_PIC5_PATH.Value = System.Convert.ToString(dr["DOC_PIC5_PATH"].ToString());
                            if (bolTest)
                            {
                                this.imgDOC_PIC5_PATH.ImageUrl = System.Convert.ToString(dr["DOC_PIC5_PATH"].ToString().Replace("\\\\Jing-preordervm\\", "http://localhost/"));
                            }
                            else
                            {
                                strDOCP = System.Convert.ToString(dr["DOC_PIC5_PATH"].ToString());
                                if (strDOCP.Substring(0, 2) == "\\\\")
                                {
                                    strDOCP = IMG_PATH + strDOCP.Substring(38);
                                }
                                this.imgDOC_PIC5_PATH.ImageUrl = strDOCP;
                            }
                        }
                        else
                        {
                            this.chkDOC_PIC5_PATH_DEL.Visible = false;
                            this.imgDOC_PIC5_PATH.Visible = false;
                        }
                        this.redDOC_SPEC.Html = arrDOC_BODY[5];
                        if (dr["DOC_SPEC_PIC"].ToString() != "")
                        {
                            this.chkDOC_SPEC_PIC.Visible = ShowChkControl;
                            this.imgDOC_SPEC_PIC.Visible = ShowImgControl;
                            this.hidDOC_SPEC_PIC.Value = System.Convert.ToString(dr["DOC_SPEC_PIC"].ToString());
                            if (bolTest)
                            {
                                this.imgDOC_SPEC_PIC.ImageUrl = System.Convert.ToString(dr["DOC_SPEC_PIC"].ToString().Replace("\\\\Jing-preordervm\\", "http://localhost/"));
                            }
                            else
                            {
                                strDOCP = System.Convert.ToString(dr["DOC_SPEC_PIC"].ToString());
                                if (strDOCP.Substring(0, 2) == "\\\\")
                                {
                                    strDOCP = IMG_PATH + strDOCP.Substring(38);
                                }
                                this.imgDOC_SPEC_PIC.ImageUrl = strDOCP;
                            }

                        }
                        else
                        {
                            this.chkDOC_SPEC_PIC.Visible = false;
                            this.imgDOC_SPEC_PIC.Visible = false;
                        }

                    }
                }
            }
        }

        private bool CheckImageInfo(Stream imgStream, ref string strCheckMessage)
        {
            //Dim nLimitSize As Integer = 1024 * Integer.Parse(Configuration.ConfigurationSettings.AppSettings("FileSize"))
            bool bReturn = true;
            System.Drawing.Image img = default(System.Drawing.Image);

            try
            {

                img = System.Drawing.Image.FromStream(imgStream);
                ImageFormat imgFormat = img.RawFormat;
                ResourceManager rm = new ResourceManager(System.Convert.ToString("smasb2b." + System.Convert.ToString(Session["langauage"])), System.Reflection.Assembly.GetExecutingAssembly());

                if (!imgFormat.Equals(ImageFormat.Jpeg))
                {
                    strCheckMessage = "上傳檔案需為JPGㄉ圖片檔!!";
                    bReturn = false;
                }
                else
                {
                    if (img.Size.Width > 600)
                    {
                        strCheckMessage = "上傳圖檔寬度超過600pix";

                        bReturn = false;
                        //Modfy By EmilyLi On 20100708 - 物品開發課阿偉告之取消此限制
                        //ElseIf Math.Abs(img.Size.Width - img.Size.Height) > 50 Then
                        // strCheckMessage = rm.GetString("MSG071")

                        //bReturn = False

                    }
                    else if (imgStream.Length > 1024 * 1024)
                    {
                        strCheckMessage = "上傳圖檔大小超過1MB";

                        bReturn = false;

                    }
                }

            }
            catch (Exception ex)
            {
                strCheckMessage = ex.Message;
                bReturn = false;
            }
            finally
            {
                if (!(img == null))
                {
                    img.Dispose();
                }
                imgStream.Seek(0, SeekOrigin.Begin);
            }

            return bReturn;
        }
        private bool SaveValue(bool bolReturnQueryPage)
        {
            try
            {
                if (this.redDOC_BODY_1.Html.Length > 4000)
                {
                    showException("文案內容一不可超過4000字!!");
                    return false;
                }
                if (this.redDOC_BODY_2.Html.Length > 4000)
                {
                    showException("文案內容二不可超過4000字!!");
                    return false;
                }
                if (this.redDOC_BODY_3.Html.Length > 4000)
                {
                    showException("文案內容三不可超過4000字!!");
                    return false;
                }
                if (this.redDOC_BODY_4.Html.Length > 4000)
                {
                    showException("文案內容四不可超過4000字!!");
                    return false;
                }
                if (this.redDOC_BODY_5.Html.Length > 4000)
                {
                    showException("文案內容五不可超過4000字!!");
                    return false;
                }
                if (this.redDOC_SPEC.Html.Length > 4000)
                {
                    showException("規格說明不可超過4000字!!");
                    return false;
                }
                string strMessage = "";
                string action = System.Convert.ToString(this.Request["action_type"].ToString());
                VENDOR LoginUser = GetLoginUser();
                //Dim OnUser As Employee = LoginUser()
                int i;

                //Tony:USE COMMON
                //ddscDataSet ddscDs = new ddscDataSet();
                com.ddsc.common.ddscDataSet ddscDs = new com.ddsc.common.ddscDataSet();

                //Tony:USE COMMON
                //ddscDataTable ddscDt = ddscDs.createDataTable("B2C_WEB_CONTENT");
                com.ddsc.common.ddscDataTable ddscDt = ddscDs.createDataTable("B2C_WEB_CONTENT");

                string sServerPath = "";
                FunctionHandler pf = new FunctionHandler();
                DataSet dsResult = new DataSet();
                if (bolTest)
                {
                    sServerPath = pf.getServerPath("VNDW0070_E");
                }
                else
                {
                    sServerPath = pf.getServerPath("VNDW0070");
                }

                // 執行新增method

                string save_action = "";

                DataBase.clearSB(sb);
                sb.Append("  select * from B2C_WEB_CONTENT ");
                //Tony : 1.修改SQL語法使用參數，不組字串
                //sb.Append(" WHERE CODE = \'" + this.txtB2C_CODE.Text + "\' AND DOC_VER=\'" + (int.Parse(this.txtDOC_VER.Text)).ToString() + "\' ");
                sb.Append(" WHERE CODE = :txtB2C_CODE AND DOC_VER=:txtDOC_VER");

                //Tony : 2.設定動態參數物件
                m_arrParam.Clear();
                m_arrParam.Add(dba.GetOracleParam(":txtB2C_CODE", this.txtB2C_CODE.Text));
                m_arrParam.Add(dba.GetOracleParam(":txtDOC_VER", (int.Parse(this.txtDOC_VER.Text)).ToString()));

                //Tony : 3.修改執行方法Overload
                //DataSet ds = DataBase.Query_CLASS(sb);
                DataSet ds = DataBase.Query_CLASS(sb, m_arrParam);

                if (!(ds == null) && ds.Tables[0].Rows[0]["ReturnCode"] != "100" && ds.Tables[0].Rows[0]["ReturnCode"] != "999")
                {
                    save_action = "upd";
                }
                else
                {
                    save_action = "add";
                }
                string strPath1 = "";
                string strPath2 = "";
                string strPath3 = "";
                string strPath4 = "";
                string strPath5 = "";
                string strSpecPath = "";
                string sFilePath1 = "";
                string sFilePath2 = "";
                string sFilePath3 = "";
                string sFilePath4 = "";
                string sFilePath5 = "";
                string sFilePathSpec = "";
                bool B1 = default(bool);
                bool B2 = default(bool);
                bool B3 = default(bool);
                bool B4 = default(bool);
                bool B5 = default(bool);
                bool BS = default(bool);
                System.Drawing.Image img = default(System.Drawing.Image);
                //Dim sr As System.IO.StreamReader

                if (this.chkDOC_PIC1_PATH_DEL.Checked == false)
                {
                    if (this.txtDOC_PIC1_PATH.Value != "")
                    {
                        if (!CheckImageInfo(txtDOC_PIC1_PATH.PostedFile.InputStream, ref strMessage))
                        {
                            showException("圖片一：" + strMessage);
                            return false;
                        }
                        strPath1 = this.txtDOC_PIC1_PATH.Value.Trim().Substring(this.txtDOC_PIC1_PATH.Value.Trim().Length - 4, 4);
                        sFilePath1 = sServerPath + "\\" + this.txtB2C_CODE.Text + "_" + this.txtDOC_VER.Text + "_1" + strPath1;

                        if (File.Exists(sFilePath1))
                        {
                            File.Delete((dynamic)sFilePath1); // 20130701 Johnny 如果此路徑已存在檔案,先將該檔刪除
                        }
                        this.txtDOC_PIC1_PATH.PostedFile.SaveAs(sFilePath1);

                        if (File.Exists((dynamic)sFilePath1))
                        {
                            B1 = true;
                        }
                    }
                    else if (this.Request["GET_OLD"] == "Y" && this.hidDOC_PIC1_PATH.Value.Trim() != "")
                    {
                        strPath1 = this.hidDOC_PIC1_PATH.Value.Trim().Substring(this.hidDOC_PIC1_PATH.Value.Trim().Length - 4, 4);
                        try
                        {
                            img = System.Drawing.Image.FromFile(hidDOC_PIC1_PATH.Value);
                        }
                        catch
                        {
                        }
                        finally
                        {
                        }
                        sFilePath1 = sServerPath + "\\" + this.txtB2C_CODE.Text + "_" + this.txtDOC_VER.Text + "_1" + strPath1;
                        img.Save(sFilePath1);
                        if (File.Exists(sFilePath1))
                        {
                            B1 = true;
                        }
                    }
                }
                else
                {
                    // 20130701 Johnny 處理 複製前一版文案時,勾選圖片刪除存檔後,前版圖檔被刪除的問題 - Start
                    //If Me.hidDOC_PIC1_PATH.Value.Trim <> "" Then
                    //    If File.Exists(hidDOC_PIC1_PATH.Value.Trim) Then
                    //        File.Delete(hidDOC_PIC1_PATH.Value.Trim)
                    //    End If
                    //End If
                    strPath1 = this.hidDOC_PIC1_PATH.Value.Trim().Substring(this.hidDOC_PIC1_PATH.Value.Trim().Length - 4, 4);
                    sFilePath1 = sServerPath + "\\" + this.txtB2C_CODE.Text + "_" + this.txtDOC_VER.Text + "_1" + strPath1;
                    if (File.Exists((dynamic)sFilePath1))
                    {
                        File.Delete((dynamic)sFilePath1);
                    }
                    // 20130701 Johnny 處理 複製前一版文案時,勾選圖片刪除存檔後,前版圖檔被刪除的問題 - End

                    sFilePath1 = "";
                    B1 = true;
                }

                if (this.chkDOC_PIC2_PATH_DEL.Checked == false)
                {
                    if (this.txtDOC_PIC2_PATH.Value != "")
                    {
                        if (!CheckImageInfo(txtDOC_PIC2_PATH.PostedFile.InputStream, ref strMessage))
                        {
                            showException("圖片二：" + strMessage);
                            return false;
                        }
                        strPath2 = this.txtDOC_PIC2_PATH.Value.Trim().Substring(this.txtDOC_PIC2_PATH.Value.Trim().Length - 4, 4);
                        sFilePath2 = sServerPath + "\\" + this.txtB2C_CODE.Text + "_" + this.txtDOC_VER.Text + "_2" + strPath2;

                        if (File.Exists((dynamic)sFilePath2))
                        {
                            File.Delete((dynamic)sFilePath2); // 20130701 Johnny 如果此路徑已存在檔案,先將該檔刪除
                        }
                        this.txtDOC_PIC2_PATH.PostedFile.SaveAs((dynamic)sFilePath2);

                        if (File.Exists((dynamic)sFilePath2))
                        {
                            B2 = true;
                        }
                    }
                    else if (this.Request["GET_OLD"] == "Y" && this.hidDOC_PIC2_PATH.Value.Trim() != "")
                    {
                        strPath2 = this.hidDOC_PIC2_PATH.Value.Trim().Substring(this.hidDOC_PIC2_PATH.Value.Trim().Length - 4, 4);
                        try
                        {
                            img = System.Drawing.Image.FromFile(hidDOC_PIC2_PATH.Value);
                        }
                        catch
                        {
                        }
                        finally
                        {
                        }

                        sFilePath2 = sServerPath + "\\" + this.txtB2C_CODE.Text + "_" + this.txtDOC_VER.Text + "_2" + strPath2;
                        img.Save(sFilePath2);
                        if (File.Exists(sFilePath2))
                        {
                            B2 = true;
                        }
                    }
                }
                else
                {
                    // 20130701 Johnny 處理 複製前一版文案時,勾選圖片刪除存檔後,前版圖檔被刪除的問題 - Start
                    //If Me.hidDOC_PIC2_PATH.Value.Trim <> "" Then
                    //    If File.Exists(hidDOC_PIC2_PATH.Value.Trim) Then
                    //        File.Delete(hidDOC_PIC2_PATH.Value.Trim)
                    //    End If
                    //End If
                    strPath2 = this.hidDOC_PIC2_PATH.Value.Trim().Substring(this.hidDOC_PIC2_PATH.Value.Trim().Length - 4, 4);
                    sFilePath2 = sServerPath + "\\" + this.txtB2C_CODE.Text + "_" + this.txtDOC_VER.Text + "_2" + strPath2;
                    if (File.Exists((dynamic)sFilePath2))
                    {
                        File.Delete((dynamic)sFilePath2);
                    }
                    // 20130701 Johnny 處理 複製前一版文案時,勾選圖片刪除存檔後,前版圖檔被刪除的問題 - End

                    sFilePath2 = "";
                    B2 = true;
                }

                if (this.chkDOC_PIC3_PATH_DEL.Checked == false)
                {

                    if (this.txtDOC_PIC3_PATH.Value != "")
                    {
                        if (!CheckImageInfo(txtDOC_PIC3_PATH.PostedFile.InputStream, ref strMessage))
                        {
                            showException("圖片三：" + strMessage);
                            return false;
                        }
                        strPath3 = this.txtDOC_PIC3_PATH.Value.Trim().Substring(this.txtDOC_PIC3_PATH.Value.Trim().Length - 4, 4);
                        sFilePath3 = sServerPath + "\\" + this.txtB2C_CODE.Text + "_" + this.txtDOC_VER.Text + "_3" + strPath3;

                        if (File.Exists((dynamic)sFilePath3))
                        {
                            File.Delete((dynamic)sFilePath3); // 20130701 Johnny 如果此路徑已存在檔案,先將該檔刪除
                        }
                        this.txtDOC_PIC3_PATH.PostedFile.SaveAs((dynamic)sFilePath3);

                        if (File.Exists((dynamic)sFilePath3))
                        {
                            B3 = true;
                        }
                    }
                    else if (this.Request["GET_OLD"] == "Y" && this.hidDOC_PIC3_PATH.Value.Trim() != "")
                    {
                        strPath3 = this.hidDOC_PIC3_PATH.Value.Trim().Substring(this.hidDOC_PIC3_PATH.Value.Trim().Length - 4, 4);
                        try
                        {
                            img = System.Drawing.Image.FromFile(hidDOC_PIC3_PATH.Value);
                        }
                        catch
                        {
                        }
                        finally
                        {
                        }

                        sFilePath3 = sServerPath + "\\" + this.txtB2C_CODE.Text + "_" + this.txtDOC_VER.Text + "_3" + strPath3;
                        img.Save(sFilePath3);
                        if (File.Exists(sFilePath3))
                        {
                            B3 = true;
                        }
                    }
                }
                else
                {
                    // 20130701 Johnny 處理 複製前一版文案時,勾選圖片刪除存檔後,前版圖檔被刪除的問題 - Start
                    //If Me.hidDOC_PIC3_PATH.Value.Trim <> "" Then
                    //    If File.Exists(hidDOC_PIC3_PATH.Value.Trim) Then
                    //        File.Delete(hidDOC_PIC3_PATH.Value.Trim)
                    //    End If
                    //End If
                    strPath3 = this.hidDOC_PIC3_PATH.Value.Trim().Substring(this.hidDOC_PIC3_PATH.Value.Trim().Length - 4, 4);
                    sFilePath3 = sServerPath + "\\" + this.txtB2C_CODE.Text + "_" + this.txtDOC_VER.Text + "_3" + strPath3;
                    if (File.Exists((dynamic)sFilePath3))
                    {
                        File.Delete((dynamic)sFilePath3);
                    }
                    // 20130701 Johnny 處理 複製前一版文案時,勾選圖片刪除存檔後,前版圖檔被刪除的問題 - End

                    sFilePath3 = "";
                    B3 = true;
                }

                if (this.chkDOC_PIC4_PATH_DEL.Checked == false)
                {

                    if (this.txtDOC_PIC4_PATH.Value != "")
                    {
                        if (!CheckImageInfo(txtDOC_PIC4_PATH.PostedFile.InputStream, ref strMessage))
                        {
                            showException("圖片四：" + strMessage);
                            return false;
                        }
                        strPath4 = this.txtDOC_PIC4_PATH.Value.Trim().Substring(this.txtDOC_PIC4_PATH.Value.Trim().Length - 4, 4);
                        sFilePath4 = sServerPath + "\\" + this.txtB2C_CODE.Text + "_" + this.txtDOC_VER.Text + "_4" + strPath4;

                        if (File.Exists((dynamic)sFilePath4))
                        {
                            File.Delete((dynamic)sFilePath4); // 20130701 Johnny 如果此路徑已存在檔案,先將該檔刪除
                        }
                        this.txtDOC_PIC4_PATH.PostedFile.SaveAs((dynamic)sFilePath4);

                        if (File.Exists((dynamic)sFilePath4))
                        {
                            B4 = true;
                        }
                    }
                    else if (this.Request["GET_OLD"] == "Y" && this.hidDOC_PIC4_PATH.Value.Trim() != "")
                    {
                        strPath4 = this.hidDOC_PIC4_PATH.Value.Trim().Substring(this.hidDOC_PIC4_PATH.Value.Trim().Length - 4, 4);
                        try
                        {
                            img = System.Drawing.Image.FromFile(hidDOC_PIC4_PATH.Value);
                        }
                        catch
                        {
                        }
                        finally
                        {
                        }

                        sFilePath4 = sServerPath + "\\" + this.txtB2C_CODE.Text + "_" + this.txtDOC_VER.Text + "_4" + strPath4;
                        img.Save(sFilePath4);
                        if (File.Exists(sFilePath4))
                        {
                            B4 = true;
                        }
                    }
                }
                else
                {
                    // 20130701 Johnny 處理 複製前一版文案時,勾選圖片刪除存檔後,前版圖檔被刪除的問題 - Start
                    //If Me.hidDOC_PIC4_PATH.Value.Trim <> "" Then
                    //    If File.Exists(hidDOC_PIC4_PATH.Value.Trim) Then
                    //        File.Delete(hidDOC_PIC4_PATH.Value.Trim)
                    //    End If
                    //End If
                    strPath4 = this.hidDOC_PIC4_PATH.Value.Trim().Substring(this.hidDOC_PIC4_PATH.Value.Trim().Length - 4, 4);
                    sFilePath4 = sServerPath + "\\" + this.txtB2C_CODE.Text + "_" + this.txtDOC_VER.Text + "_4" + strPath4;
                    if (File.Exists((dynamic)sFilePath4))
                    {
                        File.Delete((dynamic)sFilePath4);
                    }
                    // 20130701 Johnny 處理 複製前一版文案時,勾選圖片刪除存檔後,前版圖檔被刪除的問題 - End

                    sFilePath4 = "";
                    B4 = true;
                }

                if (this.chkDOC_PIC5_PATH_DEL.Checked == false)
                {
                    if (this.txtDOC_PIC5_PATH.Value != "")
                    {
                        if (!CheckImageInfo(txtDOC_PIC5_PATH.PostedFile.InputStream, ref strMessage))
                        {
                            showException("圖片五：" + strMessage);
                            return false;
                        }
                        strPath5 = this.txtDOC_PIC5_PATH.Value.Trim().Substring(this.txtDOC_PIC5_PATH.Value.Trim().Length - 4, 4);
                        sFilePath5 = sServerPath + "\\" + this.txtB2C_CODE.Text + "_" + this.txtDOC_VER.Text + "_5" + strPath5;

                        if (File.Exists((dynamic)sFilePath5))
                        {
                            File.Delete((dynamic)sFilePath5); // 20130701 Johnny 如果此路徑已存在檔案,先將該檔刪除
                        }
                        this.txtDOC_PIC5_PATH.PostedFile.SaveAs((dynamic)sFilePath5);

                        if (File.Exists((dynamic)sFilePath5))
                        {
                            B5 = true;
                        }
                    }
                    else if (this.Request["GET_OLD"] == "Y" && this.hidDOC_PIC5_PATH.Value.Trim() != "")
                    {
                        strPath5 = this.hidDOC_PIC5_PATH.Value.Trim().Substring(this.hidDOC_PIC5_PATH.Value.Trim().Length - 4, 4);
                        try
                        {
                            img = System.Drawing.Image.FromFile(hidDOC_PIC5_PATH.Value);
                        }
                        catch
                        {
                        }
                        finally
                        {
                        }

                        sFilePath5 = sServerPath + "\\" + this.txtB2C_CODE.Text + "_" + this.txtDOC_VER.Text + "_5" + strPath5;
                        img.Save(sFilePath5);
                        if (File.Exists(sFilePath5))
                        {
                            B5 = true;
                        }
                    }
                }
                else
                {
                    // 20130701 Johnny 處理 複製前一版文案時,勾選圖片刪除存檔後,前版圖檔被刪除的問題 - Start
                    //If Me.hidDOC_PIC5_PATH.Value.Trim <> "" Then
                    //    If File.Exists(hidDOC_PIC5_PATH.Value.Trim) Then
                    //        File.Delete(hidDOC_PIC5_PATH.Value.Trim)
                    //    End If
                    //End If
                    strPath5 = this.hidDOC_PIC5_PATH.Value.Trim().Substring(this.hidDOC_PIC5_PATH.Value.Trim().Length - 4, 4);
                    sFilePath5 = sServerPath + "\\" + this.txtB2C_CODE.Text + "_" + this.txtDOC_VER.Text + "_5" + strPath5;
                    if (File.Exists((dynamic)sFilePath5))
                    {
                        File.Delete((dynamic)sFilePath5);
                    }
                    // 20130701 Johnny 處理 複製前一版文案時,勾選圖片刪除存檔後,前版圖檔被刪除的問題 - End

                    sFilePath5 = "";
                    B5 = true;
                }

                if (this.chkDOC_SPEC_PIC.Checked == false)
                {
                    if (this.txtDOC_SPEC_PIC.Value != "")
                    {
                        if (!CheckImageInfo(txtDOC_SPEC_PIC.PostedFile.InputStream, ref strMessage))
                        {
                            showException("圖片規格：" + strMessage);
                            return false;
                        }
                        strSpecPath = this.txtDOC_SPEC_PIC.Value.Trim().Substring(this.txtDOC_SPEC_PIC.Value.Trim().Length - 4, 4);
                        sFilePathSpec = sServerPath + "\\" + this.txtB2C_CODE.Text + "_" + this.txtDOC_VER.Text + "_S" + strSpecPath;

                        if (File.Exists((dynamic)sFilePathSpec))
                        {
                            File.Delete((dynamic)sFilePathSpec); // 20130701 Johnny 如果此路徑已存在檔案,先將該檔刪除
                        }
                        this.txtDOC_SPEC_PIC.PostedFile.SaveAs((dynamic)sFilePathSpec);

                        if (File.Exists((dynamic)sFilePathSpec))
                        {
                            BS = true;
                        }
                    }
                    else if (this.Request["GET_OLD"] == "Y" && this.hidDOC_SPEC_PIC.Value.Trim() != "")
                    {
                        strSpecPath = this.hidDOC_SPEC_PIC.Value.Trim().Substring(this.hidDOC_SPEC_PIC.Value.Trim().Length - 4, 4);
                        try
                        {
                            img = System.Drawing.Image.FromFile(hidDOC_SPEC_PIC.Value);
                        }
                        catch
                        {
                        }
                        finally
                        {
                        }

                        sFilePathSpec = sServerPath + "\\" + this.txtB2C_CODE.Text + "_" + this.txtDOC_VER.Text + "_S" + strSpecPath;
                        img.Save(sFilePathSpec);
                        if (File.Exists(sFilePathSpec))
                        {
                            BS = true;
                        }
                    }
                }
                else
                {
                    // 20130701 Johnny 處理 複製前一版文案時,勾選圖片刪除存檔後,前版圖檔被刪除的問題 - Start
                    //If Me.hidDOC_SPEC_PIC.Value.Trim <> "" Then
                    //    If File.Exists(hidDOC_SPEC_PIC.Value.Trim) Then
                    //        File.Delete(hidDOC_SPEC_PIC.Value.Trim)
                    //    End If
                    //End If
                    strSpecPath = this.hidDOC_SPEC_PIC.Value.Trim().Substring(this.hidDOC_SPEC_PIC.Value.Trim().Length - 4, 4);
                    sFilePathSpec = sServerPath + "\\" + this.txtB2C_CODE.Text + "_" + this.txtDOC_VER.Text + "_S" + strSpecPath;
                    if (File.Exists((dynamic)sFilePathSpec))
                    {
                        File.Delete((dynamic)sFilePathSpec);
                    }
                    // 20130701 Johnny 處理 複製前一版文案時,勾選圖片刪除存檔後,前版圖檔被刪除的問題 - End

                    sFilePathSpec = "";
                    BS = true;
                }
                // 新增Row至ddscDt
                ddscDt.addNewRow();
                // 設定dscDt各欄位Value，參數一：columnName,參數二：columnValue
                ddscDt.setColumnValue("action", "string", save_action);

                if (B1)
                {
                    ddscDt.setColumnValue("DOC_PIC1_PATH", "string", sFilePath1);
                }
                //ddscDt.setColumnValue("DOC_BODY_2", "string", Me.redDOC_BODY_2.Html)
                if (B2)
                {
                    ddscDt.setColumnValue("DOC_PIC2_PATH", "string", sFilePath2);
                }
                //ddscDt.setColumnValue("DOC_BODY_3", "string", Me.redDOC_BODY_3.Html)
                if (B3)
                {
                    ddscDt.setColumnValue("DOC_PIC3_PATH", "string", sFilePath3);
                }
                //ddscDt.setColumnValue("DOC_BODY_4", "string", Me.redDOC_BODY_4.Html)
                if (B4)
                {
                    ddscDt.setColumnValue("DOC_PIC4_PATH", "string", sFilePath4);
                }
                //ddscDt.setColumnValue("DOC_BODY_5", "string", Me.redDOC_BODY_5.Html)
                if (B5)
                {
                    ddscDt.setColumnValue("DOC_PIC5_PATH", "string", sFilePath5);
                }
                //ddscDt.setColumnValue("DOC_SPEC", "string", Me.redDOC_SPEC.Html)
                if (BS)
                {
                    ddscDt.setColumnValue("DOC_SPEC_PIC", "string", sFilePathSpec);
                }

                if (save_action == "add")
                {
                    ddscDt.setColumnValue("CODE", "string", this.txtB2C_CODE.Text.Trim());
                    ddscDt.setColumnValue("CODE_TYPE", "string", this.txtB2C_CODE.Text.Trim().Substring(0, 1));
                    ddscDt.setColumnValue("DOC_VER", "string", System.Convert.ToString((int.Parse(this.txtDOC_VER.Text.Trim())).ToString()));
                    ddscDt.setColumnValue("DOC_DISABLE", "string", "N");
                    ddscDt.setColumnValue("status", "string", "1");
                    ddscDt.setColumnValue("crt_id", "string", LoginUser.VENDOR_NO);
                    ddscDt.setColumnValue("crt_date", "string", SystemDate);
                    ddscDt.setColumnValue("crt_time", "string", SystemTime);
                    ddscDt.setColumnValue("upd_id", "string", LoginUser.VENDOR_NO);
                    ddscDt.setColumnValue("upd_date", "string", SystemDate);
                    ddscDt.setColumnValue("upd_time", "string", SystemTime);
                }
                else
                {
                    ddscDt.setColumnValue("upd_id", "string", LoginUser.VENDOR_NO);
                    ddscDt.setColumnValue("upd_date", "string", SystemDate);
                    ddscDt.setColumnValue("upd_time", "string", SystemTime);
                    ddscDt.setWhereValue("CODE", this.txtB2C_CODE.Text.Trim());
                    ddscDt.setWhereValue("DOC_VER", System.Convert.ToString((int.Parse(this.txtDOC_VER.Text.Trim())).ToString()));
                    ddscDt.setWhereValue("CODE_TYPE", this.txtB2C_CODE.Text.Trim().Substring(0, 1));
                }


                if (ddscDt.Rows.Count > 1)
                {
                    ddscDs.addDataTable(ddscDt);
                }
                //'############################################################################################



                //dsResult = Update(ddscDs)

                dsResult = DataBase.Addition(ddscDs, "", (System.Array)null, (System.Array)null);

                StringBuilder sbDOC_BODY = new StringBuilder();
                string strSPLITE_FORMAT = "{0}" + strSPLIT + "{1}" + strSPLIT + "{2}" + strSPLIT + "{3}" + strSPLIT + "{4}" + strSPLIT + "{5}" + strSPLIT + "{6}" + strSPLIT + "{7}" + strSPLIT + "{8}";
                sbDOC_BODY.Append(string.Format(strSPLITE_FORMAT, ReplaceValue(HttpUtility.HtmlEncode(this.redDOC_BODY_1.Html)), ReplaceValue(HttpUtility.HtmlEncode(this.redDOC_BODY_2.Html)), ReplaceValue(HttpUtility.HtmlEncode(this.redDOC_BODY_3.Html)), ReplaceValue(HttpUtility.HtmlEncode(this.redDOC_BODY_4.Html)), ReplaceValue(HttpUtility.HtmlEncode(this.redDOC_BODY_5.Html)), ReplaceValue(HttpUtility.HtmlEncode(this.redDOC_SPEC.Html)), "", "", ""));
                //ddscDt.setColumnValue("DOC_BODY", "string", sbDOC_BODY.ToString)

                //Dim m_Col(1) As String
                //m_Col(0) = "DOC_BODY"
                //Dim m_ColVal(1) As String
                //m_ColVal(0) = sbDOC_BODY.ToString

                //UniCodeSave("B2C_WEB_CONTENT", m_Col, m_ColVal, " WHERE CODE='" + Me.txtB2C_CODE.Text.Trim() + "' AND DOC_VER='" + CInt(Me.txtDOC_VER.Text.Trim()).ToString() + "' ")
                UpdateUseParam(
                    this.txtB2C_CODE.Text.Trim(), 
                    int.Parse(this.txtDOC_VER.Text.Trim())+"", 
                    sbDOC_BODY.ToString(),
                    this.txtB2C_CODE.Text.Trim().Substring(0, 1));

                // 寫入script至client端
                if (bolReturnQueryPage)
                {
                    regScript(dsResult, "upd");
                }
                return true;
            }
            catch (Exception ex)
            {
                showException(ex.Message);
                return false;
            }

        }

        private void EnableView_DOC_SPEC_Controls(bool bolStatus)
        {

            this.redDOC_SPEC.Editable = bolStatus;
            this.redDOC_SPEC.Enabled = bolStatus;
            this.redDOC_BODY_1.Editable = bolStatus;
            this.redDOC_BODY_2.Editable = bolStatus;
            this.redDOC_BODY_3.Editable = bolStatus;
            this.redDOC_BODY_4.Editable = bolStatus;
            this.redDOC_BODY_5.Editable = bolStatus;
            this.chkDOC_SPEC_PIC.Visible = bolStatus;
            this.chkDOC_PIC1_PATH_DEL.Visible = bolStatus;
            this.chkDOC_PIC2_PATH_DEL.Visible = bolStatus;
            this.chkDOC_PIC3_PATH_DEL.Visible = bolStatus;
            this.chkDOC_PIC4_PATH_DEL.Visible = bolStatus;
            this.chkDOC_PIC5_PATH_DEL.Visible = bolStatus;
            //20130207,modi,walter,引掉
            //Me.chkDOC_SPEC_PIC.Checked = bolStatus
            //Me.chkDOC_PIC1_PATH_DEL.Checked = bolStatus
            //Me.chkDOC_PIC2_PATH_DEL.Checked = bolStatus
            //Me.chkDOC_PIC3_PATH_DEL.Checked = bolStatus
            //Me.chkDOC_PIC4_PATH_DEL.Checked = bolStatus
            //Me.chkDOC_PIC5_PATH_DEL.Checked = bolStatus
            this.txtDOC_SPEC_PIC.Visible = bolStatus;
            this.txtDOC_PIC1_PATH.Visible = bolStatus;
            this.txtDOC_PIC2_PATH.Visible = bolStatus;
            this.txtDOC_PIC3_PATH.Visible = bolStatus;
            this.txtDOC_PIC4_PATH.Visible = bolStatus;
            this.txtDOC_PIC5_PATH.Visible = bolStatus;
        }

        private void btnPreviewDoc_Click(System.Object sender, System.EventArgs e)
        {
            if (SaveValue(false))
            {
                InnerScript("alert(\'存檔成功!\');OpenPreview();");
                ShowPage(true);
            }
        }

        private void btnApproveDoc_Click(System.Object sender, System.EventArgs e)
        {
            if (SaveValue(false))
            {
                if (ApproveSave())
                {
                    InnerScript("alert(\'送審成功!\');DialogBtnExit_OnClick();");
                    ShowPage(true);
                }
            }
        }

        private bool ApproveSave()
        {
            try
            {
                DataSet ds_val = default(DataSet);
                string strEMPLOYEE_NO_S = string.Empty;
                //判斷 395408 是否尚在 Y205內
                //Tony:待處理
                DataBase.clearSB(sb);
                sb.Append(" Select * from PSN_OPEN_DATA where employee_no = \'395408\' AND DEPARTMENT_4 = \'Y205\' ");
                m_arrParam.Clear();
                //Tony : 修改執行方法Overload
                //ds_val = DataBase.Query_CLASS(sb);
                ds_val = DataBase.Query_CLASS(sb, m_arrParam);
                if (!(ds_val == null) && ds_val.Tables[0].Rows[0]["ReturnCode"] != "100" && ds_val.Tables[0].Rows[0]["ReturnCode"] != "999")
                {
                    strEMPLOYEE_NO_S = "395408";
                }
                if (string.IsNullOrEmpty(strEMPLOYEE_NO_S))
                {
                    DataBase.clearSB(sb);
                    sb.Append(" Select * from PSN_OPEN_DATA where employee_no = \'338084\' AND DEPARTMENT_4 = \'Y205\' ");
                    m_arrParam.Clear();
                    //Tony : 修改執行方法Overload
                    //ds_val = DataBase.Query_CLASS(sb)
                    ds_val = DataBase.Query_CLASS(sb, m_arrParam);
                    if (!(ds_val == null) && ds_val.Tables[0].Rows[0]["ReturnCode"] != "100" && ds_val.Tables[0].Rows[0]["ReturnCode"] != "999")
                    {
                        strEMPLOYEE_NO_S = "338084";
                    }
                }

                if (string.IsNullOrEmpty(strEMPLOYEE_NO_S))
                {
                    showException("送審錯誤，請確認送審人資訊是否正確!!");
                    return false;
                }

                DataBase.clearSB(sb);
                sb.Append(" SELECT TRANS_NO from B2C_WEB_CONTENT ");
                //Tony : 1.修改SQL語法使用參數，不組字串
                //sb.Append(" WHERE  CODE = \'" + this.txtB2C_CODE.Text + "\' AND DOC_VER = \'" + (int.Parse(this.txtDOC_VER.Text)).ToString() + "\' AND (TRANS_NO <>\'\' OR TRANS_NO IS NOT NULL) ");
                sb.Append(" WHERE  CODE = :B2C_CODE AND DOC_VER = :DOC_VER AND (TRANS_NO <>\'\' OR TRANS_NO IS NOT NULL) ");

                //Tony : 2.設定動態參數物件
                m_arrParam.Clear();
                m_arrParam.Add(dba.GetOracleParam(":B2C_CODE", this.txtB2C_CODE.Text));
                m_arrParam.Add(dba.GetOracleParam(":DOC_VER", (int.Parse(this.txtDOC_VER.Text)).ToString()));

                //Tony : 3.修改執行方法Overload
                //ds_val = DataBase.Query_CLASS(sb);
                ds_val = DataBase.Query_CLASS(sb, m_arrParam);

                bool bolFirstTime = true;
                string strTransNo = string.Empty;
                if (!(ds_val == null) && ds_val.Tables[0].Rows[0]["ReturnCode"] != "100" && ds_val.Tables[0].Rows[0]["ReturnCode"] != "999")
                {
                    bolFirstTime = false;
                    strTransNo = ds_val.Tables[1].Rows[0][0].ToString();
                }
                else
                {
                    DataBase.clearSB(sb);
                    //Tony : 1.修改SQL語法使用參數，不組字串
                    //sb.Append(" SELECT NVL(MAX(Substr(TRANS_NO,5)),\'\') TRANS_NO FROM AUT_WORK_FLOW_LOG WHERE CARD_ID =\'WV\' AND TRANS_NO LIKE \'WV" + SystemDate.Substring(2, 2) + "%\' ");
                    sb.Append(" SELECT NVL(MAX(Substr(TRANS_NO,5)),\'\') TRANS_NO FROM AUT_WORK_FLOW_LOG WHERE CARD_ID =\'WV\' AND TRANS_NO LIKE :SystemDateSub ");

                    //Tony : 2.設定動態參數物件
                    m_arrParam.Clear();
                    m_arrParam.Add(dba.GetOracleParam(":SystemDateSub", "WV" + SystemDate.Substring(2, 2) + "%"));

                    //Tony : 3.修改執行方法Overload                    
                    //ds_val = DataBase.Query_CLASS(sb);
                    ds_val = DataBase.Query_CLASS(sb, m_arrParam);

                    if (!(ds_val == null) && ds_val.Tables[0].Rows[0]["ReturnCode"] != "100" && ds_val.Tables[0].Rows[0]["ReturnCode"] != "999")
                    {
                        if (ds_val.Tables[1].Rows[0][0].ToString() == "")
                        {
                            strTransNo = "WV" + SystemDate.Substring(2, 2) + 1.ToString("D6");
                        }
                        else
                        {
                            strTransNo = "WV" + SystemDate.Substring(2, 2) + ((System.Convert.ToInt32(ds_val.Tables[1].Rows[0][0])) + 1).ToString("D6");
                        }
                    }
                    else
                    {
                        strTransNo = "WV" + SystemDate.Substring(2, 2) + 1.ToString("D6");
                    }
                }

                //Tony:USE COMMON
                //ddscDataSet ddscDs = new ddscDataSet();
                com.ddsc.common.ddscDataSet ddscDs = new com.ddsc.common.ddscDataSet();

                //Tony:USE COMMON
                //ddscDataTable ddscDt = ddscDs.createDataTable("AUT_WORK_FLOW_LOG");
                com.ddsc.common.ddscDataTable ddscDt = ddscDs.createDataTable("AUT_WORK_FLOW_LOG");

                DataSet dsResult = new DataSet();

                // 新增Row至ddscDt
                ddscDt.addNewRow();
                // 設定dscDt各欄位Value，參數一：columnName,參數二：columnValue
                ddscDt.setColumnValue("action", "string", "add");
                ddscDt.setColumnValue("SEQ_NO", "string", "20");
                ddscDt.setColumnValue("CARD_ID", "string", "WV");
                ddscDt.setColumnValue("DEPARTMENT_NO_S", "string", "Y205");
                ddscDt.setColumnValue("EMPLOYEE_NO_S", "string", strEMPLOYEE_NO_S);
                ddscDt.setColumnValue("DATE_S", "string", SystemDate);
                ddscDt.setColumnValue("TIME_S", "string", SystemTime);
                ddscDt.setColumnValue("DEPARTMENT_NO_A", "string", "Y205");
                ddscDt.setColumnValue("POS_SEQ_START", "string", "570");
                ddscDt.setColumnValue("POS_SEQ_END", "string", "999");
                ddscDt.setColumnValue("AUTHORITY", "string", "RS");
                ddscDt.setColumnValue("PATH_ID", "string", "WV");
                ddscDt.setColumnValue("STATUS", "string", "W");
                ddscDt.setColumnValue("TRANS_NO", "string", strTransNo);
                ddscDt.setColumnValue("SYSTEM_FLAG", "string", "SMAS");
                //ddscDt.setColumnValue("SEQ_NO_NUM", "string", "1")
                if (ddscDt.Rows.Count > 1)
                {
                    ddscDs.addDataTable(ddscDt);
                }

                string[] TableNameF =null;
                string[] TableNameT =null;

                if (!bolFirstTime)
                {

                    //Tony:USE COMMON
                    // ddscDataTable ddscDUt = ddscDs.createDataTable("AUT_WORK_FLOW_LOG_UPD");
                    com.ddsc.common.ddscDataTable ddscDUt = ddscDs.createDataTable("AUT_WORK_FLOW_LOG_UPD");


                    ddscDUt.addNewRow();
                    ddscDUt.setColumnValue("action", "string", "upd");
                    ddscDUt.setColumnValue("STATUS_A", "string", "W");
                    ddscDUt.setWhereValue("TRANS_NO", strTransNo);

                    if (ddscDUt.Rows.Count > 1)
                    {
                        ddscDs.addDataTable(ddscDUt);
                        TableNameF = new string[1];
                        TableNameT = new string[1];
                        TableNameF.SetValue("AUT_WORK_FLOW_LOG_UPD", 0);
                        TableNameT.SetValue("AUT_WORK_FLOW_LOG", 0);
                    }
                }



                VENDOR LoginUser = GetLoginUser();

                //Tony:USE COMMON
                //ddscDataTable ddscMt = ddscDs.createDataTable("B2C_WEB_CONTENT");
                com.ddsc.common.ddscDataTable ddscMt = ddscDs.createDataTable("B2C_WEB_CONTENT");

                ddscMt.addNewRow();
                // 設定dscDt各欄位Value，參數一：columnName,參數二：columnValue
                ddscMt.setColumnValue("action", "string", "upd");
                ddscMt.setColumnValue("TRANS_NO", "string", strTransNo);
                ddscMt.setColumnValue("status", "string", "2");
                ddscMt.setColumnValue("upd_id", "string", LoginUser.VENDOR_NO);
                ddscMt.setColumnValue("upd_date", "string", SystemDate);
                ddscMt.setColumnValue("upd_time", "string", SystemTime);
                ddscMt.setWhereValue("CODE", this.txtB2C_CODE.Text.Trim());
                ddscMt.setWhereValue("DOC_VER", System.Convert.ToString((int.Parse(this.txtDOC_VER.Text.Trim())).ToString()));
                ddscMt.setWhereValue("CODE_TYPE", this.txtB2C_CODE.Text.Trim().Substring(0, 1));
                if (ddscMt.Rows.Count > 1)
                {
                    ddscDs.addDataTable(ddscMt);
                }

                //dsResult = Update(ddscDs)


                dsResult = DataBase.Addition(ddscDs, "", TableNameF, TableNameT);
                if (dsResult.Tables[0].Rows[0]["TransResult"] == "T")
                {
                    //存檔成功
                    SendMail();
                    return true;
                }
                else
                {
                    //Dim SERROR As String = "2:{0},3:{1},4{2},RowError:{3}"
                    string SERROR = string.Format("2:{0},3:{1},4:{2},RowError:{3}", dsResult.Tables[0].Rows[0][2].ToString(), dsResult.Tables[0].Rows[0][3].ToString(), dsResult.Tables[0].Rows[0][4].ToString(), dsResult.Tables[0].Rows[0].RowError);
                    this.RegisterStartupScript("Result", "<script language=\"javascript\"> alert(\'送審失敗!! ErrorMessage：" + SERROR + "\'); </script>");
                    return false;
                }



                //InnerScript("alert('送審成功!');this.close();")
            }
            catch (Exception ex)
            {
                showException(ex.Message);
                return false;
            }
        }
        private void btnDelDoc_Click(System.Object sender, System.EventArgs e)
        {
            try
            {

                //Tony:USE COMMON
                //ddscDataSet ddscDs = new ddscDataSet();
                com.ddsc.common.ddscDataSet ddscDs = new com.ddsc.common.ddscDataSet();

                //Tony:USE COMMON
                //ddscDataTable ddscDt = ddscDs.createDataTable("B2C_WEB_CONTENT");
                com.ddsc.common.ddscDataTable ddscDt = ddscDs.createDataTable("B2C_WEB_CONTENT");

                DataSet dsResult = new DataSet();
                ddscDt.addNewRow();
                ddscDt.setColumnValue("action", "string", "del");
                ddscDt.setColumnValue("CODE", "string", this.txtB2C_CODE.Text);
                ddscDt.setColumnValue("DOC_VER", "string", int.Parse(this.txtDOC_VER.Text));
                ddscDt.setWhereValue("CODE", this.txtB2C_CODE.Text);
                ddscDt.setWhereValue("DOC_VER", int.Parse(this.txtDOC_VER.Text));
                if (ddscDt.Rows.Count > 1)
                {
                    ddscDs.addDataTable(ddscDt);
                }
                //'############################################################################################

                //dsResult = Update(ddscDs)

                dsResult = DataBase.Addition(ddscDs, "", (System.Array)null, (System.Array)null);
                // 寫入script至client端
                regScript(dsResult, "del");

            }
            catch (Exception ex)
            {
                showException(ex.Message);
            }
            finally
            {
                if (this.hidDOC_PIC1_PATH.Value.Trim() != "")
                {
                    if (File.Exists(hidDOC_PIC1_PATH.Value.Trim()))
                    {
                        File.Delete(hidDOC_PIC1_PATH.Value.Trim());
                    }
                }
                if (this.hidDOC_PIC2_PATH.Value.Trim() != "")
                {
                    if (File.Exists(hidDOC_PIC2_PATH.Value.Trim()))
                    {
                        File.Delete(hidDOC_PIC2_PATH.Value.Trim());
                    }
                }
                if (this.hidDOC_PIC3_PATH.Value.Trim() != "")
                {
                    if (File.Exists(hidDOC_PIC3_PATH.Value.Trim()))
                    {
                        File.Delete(hidDOC_PIC3_PATH.Value.Trim());
                    }
                }
                if (this.hidDOC_PIC4_PATH.Value.Trim() != "")
                {
                    if (File.Exists(hidDOC_PIC4_PATH.Value.Trim()))
                    {
                        File.Delete(hidDOC_PIC4_PATH.Value.Trim());
                    }
                }
                if (this.hidDOC_PIC5_PATH.Value.Trim() != "")
                {
                    if (File.Exists(hidDOC_PIC5_PATH.Value.Trim()))
                    {
                        File.Delete(hidDOC_PIC5_PATH.Value.Trim());
                    }
                }
                if (this.hidDOC_SPEC_PIC.Value.Trim() != "")
                {
                    if (File.Exists(hidDOC_SPEC_PIC.Value.Trim()))
                    {
                        File.Delete(hidDOC_SPEC_PIC.Value.Trim());
                    }
                }
            }
        }

        private void btnSaveDoc_Click(System.Object sender, System.EventArgs e)
        {
            if (SaveValue(false))
            {
                InnerScript("alert(\'存檔成功!\');");
                ShowPage(true);
            }
        }
        public string ReplaceValue(string ValueHtml)
        {
            //把所有<a>link</a> 取代為link ,不加html語法
            string strCOPY;
            string strURL = SelectUrl(ValueHtml);
            while (strURL != "")
            {
                //放入找出的<a>link</a>
                //strCOPY = strURL
                //取代網址
                ValueHtml = ValueHtml.Replace(strURL, ""); //strCOPY.Substring(strCOPY.ToUpper.IndexOf(">") + 1, strCOPY.ToUpper.IndexOf("</A>") - strCOPY.ToUpper.IndexOf(">") - 1))
                strURL = SelectUrl(ValueHtml);
            }


            //------------------------------------------
            //http://-----------------------------------
            strURL = SelectUrlHttp(ValueHtml, "HTTP://");
            while (strURL != "")
            {
                ValueHtml = ValueHtml.Replace(strURL, "");
                strURL = SelectUrlHttp(ValueHtml, "HTTP://");
            }
            //------------------------------------------
            //https://----------------------------------
            strURL = SelectUrlHttp(ValueHtml, "HTTPS://");
            while (strURL != "")
            {
                ValueHtml = ValueHtml.Replace(strURL, "");
                strURL = SelectUrlHttp(ValueHtml, "HTTPS://");
            }
            //-----------------------------------------
            ValueHtml = Strings.Replace(ValueHtml, "script", "", 1, -1, (Microsoft.VisualBasic.CompareMethod)1);
            ValueHtml = Strings.Replace(ValueHtml, "http://", "", 1, -1, (Microsoft.VisualBasic.CompareMethod)1);
            ValueHtml = Strings.Replace(ValueHtml, "https://", "", 1, -1, (Microsoft.VisualBasic.CompareMethod)1);
            ValueHtml = Strings.Replace(ValueHtml, ".com", "", 1, -1, (Microsoft.VisualBasic.CompareMethod)1);
            ValueHtml = Strings.Replace(ValueHtml, ".org", "", 1, -1, (Microsoft.VisualBasic.CompareMethod)1);
            ValueHtml = Strings.Replace(ValueHtml, ".net", "", 1, -1, (Microsoft.VisualBasic.CompareMethod)1);
            ValueHtml = Strings.Replace(ValueHtml, "asp", "", 1, -1, (Microsoft.VisualBasic.CompareMethod)1);
            ValueHtml = Strings.Replace(ValueHtml, "aspx", "", 1, -1, (Microsoft.VisualBasic.CompareMethod)1);
            ValueHtml = Strings.Replace(ValueHtml, "php", "", 1, -1, (Microsoft.VisualBasic.CompareMethod)1);
            ValueHtml = Strings.Replace(ValueHtml, "htm", "", 1, -1, (Microsoft.VisualBasic.CompareMethod)1);
            ValueHtml = Strings.Replace(ValueHtml, "html", "", 1, -1, (Microsoft.VisualBasic.CompareMethod)1);
            ValueHtml = Strings.Replace(ValueHtml, "xml", "", 1, -1, (Microsoft.VisualBasic.CompareMethod)1);
            ValueHtml = Strings.Replace(ValueHtml, "jsp", "", 1, -1, (Microsoft.VisualBasic.CompareMethod)1);
            ValueHtml = Strings.Replace(ValueHtml, ".tw", "", 1, -1, (Microsoft.VisualBasic.CompareMethod)1);


            return ValueHtml;
        }
        //取代連結<a></a>
        public string SelectUrl(string ValueUrl)
        {
            //找出URL,<a></a>
            if (ValueUrl.ToUpper().IndexOf("<A") >= 0 && ValueUrl.ToUpper().IndexOf("</A>") >= 0 && (ValueUrl.ToUpper().IndexOf("<A") < ValueUrl.ToUpper().IndexOf("</A>")))
            {
                string strURL = ValueUrl.Substring(ValueUrl.ToUpper().IndexOf("<A"), ValueUrl.ToUpper().IndexOf("</A>") + 4 - ValueUrl.ToUpper().IndexOf("<A"));
                return strURL;
            }
            else
            {
                return "";
            }
        }

        //取代http://
        public string SelectUrlHttp(string ValueUrl, string strReplace)
        {
            //找出URL,<a></a>
            if (ValueUrl.ToUpper().IndexOf(strReplace.ToUpper()) >= 0)
            {
                string CopyURL = ValueUrl.Substring(ValueUrl.ToUpper().IndexOf(strReplace.ToUpper()));
                if (CopyURL.IndexOf(" ") >= 0)
                {
                    CopyURL = CopyURL.Substring(0, CopyURL.IndexOf(" "));
                    return CopyURL;
                }
            }
            return "";
        }
        private void SendMail()
        {
            int i = 0;
            string mailto = "";
            string mailsbject = "";
            string mailbody = "";
            DataSet dsType = default(DataSet);
            DataSet ds;
            string dname = "";
            dbAccess dba = new dbAccess();
            try
            {

                string SelectCommandText = "";
                VENDOR LoginUser = GetLoginUser();
                mailsbject = "樂e購廠商" + LoginUser.VENDOR_NO + "-" + LoginUser.NAME + "已建立" + this.txtB2C_CODE.Text + "_" + txtB2C_CODE_NAME.Text + "商品文案資料，請負責人儘速至系統審核。 ";
                mailbody = "樂e購廠商" + LoginUser.VENDOR_NO + "-" + LoginUser.NAME + "已建立" + this.txtB2C_CODE.Text + "_" + txtB2C_CODE_NAME.Text + "商品文案資料，請負責人儘速至系統審核";

                if (bolTest)
                {
                    //測試環境用
                    //FunctionHandler.SentMail(mailsbject, "joekcchou@evaair.com", "", "", EMAIL, mailbody)
                    //FunctionHandler.SentMail(mailsbject, mailto, "joekcchou@evaair.com", "", "joekcchou@evaair.com", mailbody)
                }
                else
                {
                    //FunctionHandler.SentMail(mailsbject, mailto, "joekcchou@evaair.com", "", "joekcchou@evaair.com", mailbody)
                    //正式環境用
                    dname = "PSN_OPEN_DATA";
                    SelectCommandText = "SELECT EMPLOYEE_NO,DECODE(EMAIL,\'lindawu@evaair.com\',\'lindascwu@evaair.com\',EMAIL) AS EMAIL FROM PSN_OPEN_DATA WHERE DEPARTMENT = \'Y205\'";
                    dsType = dba.runExecuteQuery(dname, SelectCommandText);
                    for (i = 0; i <= dsType.Tables[1].Rows.Count - 1; i++)
                    {
                        mailto = mailto + ";" + dsType.Tables[1].Rows[i]["EMAIL"].ToString();
                    }
                    FunctionHandler.SentMail(mailsbject, mailto, "joekcchou@evaair.com", "", "smasb2b@evaair.com", mailbody);

                    // 測試用 - tmp Add
                    //FunctionHandler.SentMail(mailsbject, "joekcchou@evaair.com", "", "", "joekcchou@evaair.com", mailbody)
                }


            }
            catch (Exception ex)
            {
                showException(ex.StackTrace);
            }

        }

        public void UpdateUseParam(string CODE, string DOC_VER, string DOC_BODY , string CODE_TYPE)
        {

            //dbConnection dba = new dbConnection();
            //System.Data.OleDb.OleDbConnection myConnection = dba.getOleDbConnection();
            //System.Data.OleDb.OleDbCommand myCommand = myConnection.CreateCommand();
            //string strSQL = "UPDATE B2C_WEB_CONTENT SET DOC_BODY = ? WHERE CODE = \'" + CODE + "\' AND DOC_VER=\'" + DOC_VER + "\'";

            //Tony:變更為使用參數
            dbAccess dba = new dbAccess();
            ArrayList m_arrParam = new ArrayList();
            string strSQL = "UPDATE B2C_WEB_CONTENT SET DOC_BODY = :DOC_BODY WHERE CODE = :CODE AND DOC_VER=:DOC_VER AND CODE_TYPE=:CTYPE";
            //string strSQL = string.Format("UPDATE B2C_WEB_CONTENT SET DOC_BODY = '{0}' WHERE CODE = '{1}' AND DOC_VER='{2}' AND  CODE_TYPE='{3}'"
                //,DOC_BODY , CODE,DOC_VER ,CODE_TYPE );

            try
            {
                //myConnection.Open();
                //myCommand.CommandText = strSQL;
                //myCommand.Parameters.Add("@DOC_BODY", DOC_BODY);
                //myCommand.ExecuteNonQuery();

                m_arrParam.Add(dba.GetOracleParam(":CODE", CODE));
                m_arrParam.Add(dba.GetOracleParam(":DOC_VER", DOC_VER));
                m_arrParam.Add(dba.GetOracleParam(":DOC_BODY", DOC_BODY));
                m_arrParam.Add(dba.GetOracleParam(":CTYPE", CODE_TYPE));
                dba.runExecuteNonQuery(strSQL, m_arrParam);
            }
            catch (System.Data.OleDb.OleDbException ex)
            {
                throw (ex);
            }
            finally
            {
                //myConnection.Close();
            }

        }
    }

}
